package d1104;

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Spinner;

public class MyDialog {

	private static final SelectionListener SelectionAdapter = null;
	protected static Shell shell;
	private Text text;
	private Text text_1;

	public MyDialog(Shell shell2, int none) {
		// TODO Auto-generated constructor stub
	}

	/**
	 * Launch the application.
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			MyDialog window = new MyDialog(shell, 0);
			window.open();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Open the window.
	 */
	public void open() {
		Display display = Display.getDefault();
		createContents();
		shell.open();
		shell.layout();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
	}

	/**
	 * Create contents of the window.
	 */
	protected void createContents() {
		shell = new Shell();
		shell.setSize(423, 325);
		shell.setText("个人信息");
		
		Label label = new Label(shell, SWT.NONE);
		label.setBounds(33, 29, 76, 20);
		label.setText("用户名：");
		
		text = new Text(shell, SWT.BORDER);
		text.setBounds(103, 26, 234, 26);
		
		Label lblNewLabel = new Label(shell, SWT.NONE);
		lblNewLabel.setBounds(33, 67, 76, 20);
		lblNewLabel.setText("密码：");
		
		text_1 = new Text(shell, SWT.BORDER | SWT.PASSWORD);
		text_1.setBounds(103, 67, 234, 26);
		
		Label lblNewLabel_1 = new Label(shell, SWT.NONE);
		lblNewLabel_1.setBounds(33, 109, 76, 20);
		lblNewLabel_1.setText("学历：");
		
		Button btnRadioButton = new Button(shell, SWT.RADIO);
		btnRadioButton.setBounds(103, 109, 119, 20);
		btnRadioButton.setText("高中");
		
		Button btnRadioButton_1 = new Button(shell, SWT.RADIO);
		btnRadioButton_1.setBounds(171, 109, 119, 20);
		btnRadioButton_1.setText("专科");
		
		Button btnRadioButton_2 = new Button(shell, SWT.RADIO);
		btnRadioButton_2.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
			}
		});
		btnRadioButton_2.setBounds(244, 109, 149, 20);
		btnRadioButton_2.setText("本科");
		
		Label lblNewLabel_2 = new Label(shell, SWT.NONE);
		lblNewLabel_2.setBounds(33, 135, 76, 20);
		lblNewLabel_2.setText("社团：");
		
		Button btnCheckButton = new Button(shell, SWT.CHECK);
		btnCheckButton.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
			}
		});
		btnCheckButton.setBounds(103, 135, 119, 20);
		btnCheckButton.setText("吉他社");
		
		Button button = new Button(shell, SWT.CHECK);
		button.setBounds(171, 135, 121, 20);
		button.setText("滑板社");
		
		Button button_1 = new Button(shell, SWT.CHECK);
		button_1.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
			}
		});
		button_1.setBounds(254, 135, 121, 20);
		button_1.setText("读书沙龙");
		
		Label lblNewLabel_3 = new Label(shell, SWT.NONE);
		lblNewLabel_3.setBounds(33, 161, 76, 20);
		lblNewLabel_3.setText("籍贯：");
		
		Combo combo = new Combo(shell, SWT.NONE);
		combo.setItems(new String[] {});
		combo.setBounds(103, 161, 234, 28);
		
		Label lblNewLabel_4 = new Label(shell, SWT.NONE);
		lblNewLabel_4.setBounds(33, 192, 76, 20);
		lblNewLabel_4.setText("工资：");
		
		Spinner spinner = new Spinner(shell, SWT.BORDER);
		spinner.setBounds(103, 195, 234, 26);
		
		Button btnNewButton = new Button(shell, SWT.NONE);
		btnNewButton.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
			}
		});
		btnNewButton.setBounds(101, 227, 98, 30);
		btnNewButton.setText("保存");
		
		Button btnNewButton_1 = new Button(shell, SWT.NONE);
		btnNewButton_1.setBounds(239, 227, 98, 30);
		btnNewButton_1.setText("取消");

	
	Text mntmJavaProject = new Text(spinner, 0);
	///////////////////////////////////////////////////
	//addSelectionListener 添加选择事务监听器
	//Selection: 鼠标点击按钮，下拉框选择
	//Listener :监听器
	//事务监听器经常写成：匿名类方式
	mntmJavaProject.addSelectionListener(new SelectionAdapter() {
		
		public void widegetSelected(SelectionEvent e) {
			//点击菜单项，触发的事件函数
			MessageBox mbox = new MessageBox(shell);
			mbox.setText("系统提示");
			mbox.setMessage("这是一个消息框");
			mbox.open();
		}
	});
	
	Text menuItem = new Text(spinner, 0);
	menuItem.addSelectionListener(new SelectionAdapter() {
		
		public void widgeSelected(SelectionEvent e) {
			//SWT.NONE 无样式==> 默认样式
			MyDialog dialog = new MyDialog(shell,SWT.None);
			dialog.open();
		}
	});
	
	
	
	}
}
